(function() {
	// swipe 

	var $page_index = $("#page_index");
	$("body").swipe({
		swipe:function(event, direction, distance, duration, fingerCount)  {
			console.log(direction);
			if( direction == 'left'){
				$page_index.removeClass('open');
			}else if( direction == 'right') {
				$page_index.addClass('open');
			}
		}
	});

	// slide
	var winW = window.innerWidth;
	var cBox = $("#js_content_box");
	var box_lis = $("#js_content_box li");
	var cHandler = $("#scroll_position");
	var handler_lis ;
	var slide = {
		d : 3500,
		idx : 0,
		init:function() {
			var len = this.len= cBox.find('li').length;

			var lis = "";
			for (var i = 0; i<len; i++) {
				lis += '<li></li>';
			};
			cHandler.html(lis);
			handler_lis = $("#scroll_position li");
			return this;
		},
		run:function() {
			box_lis.hide();
			box_lis.eq(this.idx).fadeIn(1000);
			handler_lis.removeClass('on');
			handler_lis.eq(this.idx).addClass('on');

			this.idx = this.idx+1 == this.len ?  0 : this.idx+1 ;

			setTimeout(function() {
				slide.run.call(slide);
			},this.d);
		}
	}

	slide.init().run();


})();